<!DOCTYPE HTML>
<html class="x-admin-sm">
<head>
    <th:block th:insert="head/head :: common_head"></th:block>
</head>
<body onload="init('yjhm')">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card" style="margin: 10px;">
                    <div class="layui-tab layui-tab-brief">
                        <div class="layui-tab-content" >
                            <div class="layui-tab-item layui-show">
                                <form class="layui-form layui-form-pane" autocomplete="off">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class='x-red'>*</span>邮件号吗：
                                        </label>
                                        <div class="layui-input-block">
                                            <input type="text" id="yjhm" name="yjhm" class="layui-input">
                                        </div>
                                    </div>
                                </form>
                                <button class="layui-btn" lay-submit="" lay-filter="*" id="bc">
                                    确认登记
                                </button>
                                <div style="height:100px;"></div>
                            </div>

                        </div>
                    </div>
                </div>
        </div>
    </div>
</div>
</div>
<th:block th:insert="head/head :: common_jsfiles"></th:block>
<script>
    /**
     * lx 0 表示新增  1 表示修改 id 为主键
     * 所有增改页面，载入时，都是通过doFirst回调renderForm
     *
     */
    var id="[[${id}]]";
    var url = "[[${serverUrl}]]/stamp/order/fhdj";
    var ms="stamp_fhdj";
    function on_result(result)
    {
        if (result.code!=500)
        {
           if (result.code==0){
                //新增成功
                layer.msg(result.msg, { time: 1000 }, function() {
                    parent.hd();
                });//失败时只提示信息，不关闭弹出层且不刷新父页
            } else {
               layer.msg(result.msg);
               $('#bc').removeClass("layui-btn-disabled").attr("disabled",false);
            }
        }
        else
        {
            layer.msg(result.msg);
            $('#bc').removeClass("layui-btn-disabled").attr("disabled",false);
        }
    }
    //表单相关
    layui.use(['form'], function(){
        var form = layui.form;

        function onSave(nonce_zhi){
            //获取提交令牌
            if (is_null(nonce_zhi)){
                $('#bc').removeClass("layui-btn-disabled").attr("disabled",false);
                layer.msg("没有获取到操作凭证！请重试！",{icon:2,anim:6});
                return false;
            }
            var jsonData = {
                yjhm: $("#yjhm").val(),
                id: id,
                nonce_ms:ms,
                nonce_zhi:nonce_zhi,
                timestamp:new Date().getTime()
            };
            var sendStr = {
                data:encrypt_str(JSON.stringify(jsonData),localStorage.getItem("a"),localStorage.getItem("b"))
            };
            post_json_token(url,JSON.stringify(sendStr),"数据提交中...");
        }

        //监听提交
        form.on('submit(*)', function(data){
            if ($("#yjhm").val()==""){
                layer.msg("请输入邮件号码！",{icon:2,anim:6});
                init('yjhm');
                return false;
            }
            if (!confirm("是否确定操作？")) return false;

            $('#bc').addClass("layui-btn-disabled").attr("disabled",true);
            psot_get_nonce(ms,"[[${serverUrl}]]/getnonce",onSave)
            return false;
        });
    });

</script>
</body>
</html>